home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 1.1 KB | 69 lines | [TEXT/MPS ] |
- /*
- File: StackList.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __STACKLIST__
- #include "StackList.h"
- #endif
-
- #pragma segment SortedList
-
- /***********************************|****************************************/
-
- const void*
- TStack::Pop ()
- {
- if ( fTop )
- {
- const void* value = fTop->fValue;
- TStackLink* next = fTop->fNext;
- fTop->fNext = 0;
- fTop = next;
- --fLength;
- return value;
- }
- else
- {
- return 0;
- }
- }
-
- /***********************************|****************************************/
-
- void
- TStack::Clear ()
- {
- delete fTop;
- fTop = 0;
- fLength = 0;
- }
-
- /***********************************|****************************************/
-
- Boolean
- TStack::Contains ( const void* value ) const
- {
- const TStackLink* current = fTop;
-
- while ( current )
- {
- if ( current->fValue == value )
- return true;
- else
- current = current->fNext;
- }
-
- return false;
- }
-
- /***********************************|****************************************/
-